<!--{include(file='head.html')}-->
<script src="template/jslib/xheditor/xheditor.js" type="text/javascript"></script>
<script type="text/javascript" src="template/jslib/date/WdatePicker.js"></script>
<script type="text/javascript" src="template/jslib/tbox/tbox.js"></script>
<link rel="stylesheet" href="template/jslib/tbox/tbox.css" type="text/css" />


<div id="wrap">
	<!--{include('left.html')}-->
	
	<div id="maincont">
		<b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
		<form action="<!--{url('admin','tuan','tuansave')}-->" method="post" name="submitform" id="submitform">
		<div id="main_c">
		<!--{if $opertype == "edit"}-->
			<ul class="bk">
				<li>
					<label><em>*</em>主题：</label>
					<p>
						<input class="input_tx short" value="<!--{$tuan.subject}-->" name="subject" id="subject" type="text"/>
					</p>
				</li>
				<li>
					<label><em>*</em>时间：</label>
					<p>
						<input class="input_tx short" value="<!--{date('Y-m-d',$tuan.begintime)}-->" name="begintime" id="begintime" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
						-
						<input class="input_tx short" value="<!--{date('Y-m-d',$tuan.endtime)}-->" name="endtime" id="endtime" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
					</p>
				</li>
				<li>
					<label><em>*</em>商品：</label>
					<p>
						<a href="javascript:void(0);" onclick="ItemSelect.popitem();return false;" class="bt_style2">选择商品</a>
						<span class="foritem"><!--{$tuan.itemname}--></span>
						<input type="hidden" name="itemid" value="<!--{$tuan.itemid}-->" id="itemid" />
					</p>
				</li>
				<li>
					<label><em>*</em>团购价格：</label>
					<div class="listp">
						<input class="input_tx short" value="<!--{getPrice($tuan.price)}-->" name="price" id="price" type="text"/>
					</div>
				</li>
			</ul>

			<ul class="bk">
				<li>
					<label>详情：</label>
					<p>
						<textarea name="desc" id="desc"><!--{$tuandesc.desc}--></textarea>
					</p>
				</li>
			</ul>

			
		<!--{elseif $opertype=="add"}-->
			<ul class="bk">
				<li>
					<label><em>*</em>主题：</label>
					<p>
						<input class="input_tx short" value="" name="subject" id="subject" type="text"/>
					</p>
				</li>
				<li>
					<label><em>*</em>时间：</label>
					<p>
						<input class="input_tx short" value="" name="begintime" id="begintime" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
						-
						<input class="input_tx short" value="" name="endtime" id="endtime" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
					</p>
				</li>
				<li>
					<label><em>*</em>商品：</label>
					<p>
						<a href="javascript:void(0);" onclick="ItemSelect.popitem();return false;" class="bt_style2">选择商品</a>
						<span class="foritem"></span>
						<input type="hidden" name="itemid" value="" id="itemid" />
					</p>
				</li>
				<li>
					<label><em>*</em>团购价格：</label>
					<div class="listp">
						<input class="input_tx short" value="" name="price" id="price" type="text"/>
					</div>
				</li>
			</ul>

			<ul class="bk">
				<li>
					<label>详情：</label>
					<p>
						<textarea name="desc" id="desc"></textarea>
					</p>
				</li>
			</ul>
		<!--{/if}-->
			<div class="bt_bk2">
				<input type="hidden" value="<!--{$opertype}-->" name="opertype" />
				<input type="hidden" value="<!--{def($tuanid)}-->" name="tuanid" />
				<a href="javascript:void(0);" class="btn" onclick="jssubmit('tuan');return false;"><span>保存</span></a>
			</div>
		</div>
		</form>
		<b class="b4b"></b><b class="b3b"></b><b class="b2b"></b><b class="b1b"></b>
	</div>
</div>
<!--{include(file='foot.html')}-->

<script type="text/javascript">
var ItemSelect = {
	popitem:function() {//弹出item选择框
		$.tbox.popup("<!--{url('admin','select','selectitem','type=select')}-->");
	},
	selectitem:function(itemid){//选择item
		$("#itemid").val(itemid);
		$(".foritem").text($("#item_" + itemid).text());
		$.tbox.close();
	},
	selecttuan:function(){//选择tuan
		var ele = $("#listtbody").find("input:checked");
		var ids = $.util.checkedval(ele);
		$(ids).each(function(k,id){
			$html = $("#fortuan").clone();
			$(".tuanimg",$html).html($("#img_"+id).html());
			$(".tuanname",$html).text($("#item_"+id).text());
			$("#tuan").append($html.html().replace(/{itemid}/gm,id));
		});
		$.tbox.close();
	}
}
$(function(){
	$("#desc").xheditor({upImgUrl:"<!--{url('admin','uploadfile','pic')}-->"});
});
</script>